Skip to main content

All Questions

Tagged with
0votes
1answer
110views

uncomment the line upon search string while ignoring case in a file

Below is my cron file entries: #Ansible: test2 */15 * * * * ansible-playbook /web/playbooks/automation/detect401MORTEN/va_action.yml | tee -a /web/playbooks/automation/detect401MORTEN/cron.out # #...
Ashar's user avatar
-1votes
1answer
54views

Search & replace for a string separated by whitespace upon substring match found

Below is a sample file content: cat sample.txt -server -XX:+UseParallelGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+AggressiveHeap -XX:+PrintHeapAtGC -Djava.util.logging.FileHandler....
Ashar's user avatar
1vote
5answers
1kviews

Replace hyphen(s) with underscore(s) within angle brackets in a file

I’m aware of how to replace string; e.g., replace hyphen with underscore in a file. However, I wish to replace all hyphens with underscore for all text that falls within angle brackets in a given file....
Ashar's user avatar
-1votes
2answers
652views

Search and replacing a string on specific file extensions with the folder name

I want to find a string ("AAA") in an specific file extension ("*.txt") inside a directory tree (../MyParentFolder), and replace it with the subfolder name (MySubfolder). I know a ...
Amir Ghorbani's user avatar
0votes
2answers
243views

how to use sed to replace a string of characters in quotes

I want to use sed to replace the current time in the code below time0=$(date '+%Y-%m-%d') time1=$(date '+%H:%M:%S') time=$(echo ""$time0"T"$time1"Z") replace $time on ...
toilaai's user avatar
2votes
2answers
383views

Vendor from MAC address (first three parts)

How you can get the first three parts from MAC address? $ mac=11:22:33:44:55:66 $ vendor=${${mac//:/}:0:6} bash: ${${mac//:/}:0:6}: bad substitution ${mac//:/} removes : and :0:6 should get the first ...
raspi's user avatar
  • 1,446
-1votes
1answer
53views

Replace certain strings

I've got a text file containing the following: yyyy-mm-dd, 12:34/s-show/... yyyy-mm-dd, 13:24/s-show/... yyyy-mm-dd, 14:32/s-show/... yyyy-mm-dd/s-show Now I'd like to replace the substrings before /...
X3nion's user avatar
0votes
2answers
494views

Replace first word keeping file alignment

I am trying to write a Shell script to edit an input file. Data is structured in the input file as follow: 1000␣␣␣␣␣␣␣␣␣␣␣␣: final time 1000 : print time 0.1 : time step The ...
user avatar
1vote
2answers
5kviews

Replace multi line string with multi line string without escaping by hand

Say I have a text file text.txt and I want to replace a (multi-line) string that is contained in before.txt with another string that is contained in after.txt, how do I do that? (I dont want to use ...
Kvothe's user avatar
2votes
2answers
617views

Easiest way to get `+` indented `tree` output

I need to replace indentation in tree output with + signs so that instead of this: $ tree --noreport dir dir ├── dir1 │ ├── file1 │ └── file2 └── dir2 ├── file1 └── file2 it'd print this: ...
cprn's user avatar
  • 1,035
0votes
4answers
5kviews

Find and replace after a string after a specific character

I have the following lines in my input file and I would like to replace all the text after "=" sign with a new string, say "good". Again, I would like to do this only for certain strings in the line....
veekay's user avatar
0votes
1answer
217views

Extracting multiple strings, according to a pattern, in a bash script

I'm writing a shell script to generate a directory listing. as an input a receive a long html string : https://www.mycompany.com/posts/aureliaflore_china-seoul-startup-activity-6571925510337728512-...
magique's user avatar
1vote
1answer
2kviews

Bash replace special character '

All the questions and answers i already read are not my solution. So, all i want to do is to replace the special char ' in bash. This works: A="abc" B="${A//[b]/x}" But this does not work: A="a'b" ...
MSauer's user avatar
1vote
4answers
312views

Replace string in multiple files (same directory) with condition

Example: File1: Name: abc Number: 325 Code: 0 File2: Name: xyz Number: 578 Code: 0 File3: Name: ttt Number: 356 Code: 0 File4: Name: nnn Number: 228 Code: 0 File5: Name: bnb Number: 434 Code: 0 ...
Siniša Babić's user avatar
1vote
3answers
4kviews

How to find and replace seemingly a tab char using sed?

I have a line looks like this: some.com *.some.com The space is seemingly a tab space because when I move the keyboard arrow, one move will move me to the end of it (it does not seem multiple ...
user9371654's user avatar

153050per page
close